<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">


    <title>数据 - AdminLTE2定制版</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">


    <!-- Tell the browser to be responsive to screen width -->
    <meta
            content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"
            name="viewport">
    <!-- Bootstrap 3.3.6 -->
    <!-- Font Awesome -->
    <!-- Ionicons -->
    <!-- iCheck -->
    <!-- Morris chart -->
    <!-- jvectormap -->
    <!-- Date Picker -->
    <!-- Daterange picker -->
    <!-- Bootstrap time Picker -->
    <!--<link rel="stylesheet" href="${pageContext.request.contextPath}/${pageContext.request.contextPath}/${pageContext.request.contextPath}/plugins/timepicker/bootstrap-timepicker.min.css">-->
    <!-- bootstrap wysihtml5 - text editor -->
    <!--数据表格-->
    <!-- 表格树 -->
    <!-- select2 -->
    <!-- Bootstrap Color Picker -->
    <!-- bootstrap wysihtml5 - text editor -->
    <!--bootstrap-markdown-->
    <!-- Theme style -->
    <!-- AdminLTE Skins. Choose a skin from the css/skins
           folder instead of downloading all of them to reduce the load. -->
    <!-- Ion Slider -->
    <!-- ion slider Nice -->
    <!-- bootstrap slider -->
    <!-- bootstrap-datetimepicker -->

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->


    <!-- jQuery 2.2.3 -->
    <!-- jQuery UI 1.11.4 -->
    <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
    <!-- Bootstrap 3.3.6 -->
    <!-- Morris.js charts -->
    <!-- Sparkline -->
    <!-- jvectormap -->
    <!-- jQuery Knob Chart -->
    <!-- daterangepicker -->
    <!-- datepicker -->
    <!-- Bootstrap WYSIHTML5 -->
    <!-- Slimscroll -->
    <!-- FastClick -->
    <!-- iCheck -->
    <!-- AdminLTE App -->
    <!-- 表格树 -->
    <!-- select2 -->
    <!-- bootstrap color picker -->
    <!-- bootstrap time picker -->
    <!--<script src="${pageContext.request.contextPath}/${pageContext.request.contextPath}/${pageContext.request.contextPath}/plugins/timepicker/bootstrap-timepicker.min.js"></script>-->
    <!-- Bootstrap WYSIHTML5 -->
    <!--bootstrap-markdown-->
    <!-- CK Editor -->
    <!-- InputMask -->
    <!-- DataTables -->
    <!-- ChartJS 1.0.1 -->
    <!-- FLOT CHARTS -->
    <!-- FLOT RESIZE PLUGIN - allows the chart to redraw when the window is resized -->
    <!-- FLOT PIE PLUGIN - also used to draw donut charts -->
    <!-- FLOT CATEGORIES PLUGIN - Used to draw bar charts -->
    <!-- jQuery Knob -->
    <!-- Sparkline -->
    <!-- Morris.js charts -->
    <!-- Ion Slider -->
    <!-- Bootstrap slider -->
    <!-- bootstrap-datetimepicker -->
    <!-- 页面meta /-->

    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/ionicons/css/ionicons.min.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/iCheck/square/blue.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/morris/morris.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/datepicker/datepicker3.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/datatables/dataTables.bootstrap.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.theme.default.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/select2/select2.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/colorpicker/bootstrap-colorpicker.min.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/css/style.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.skinNice.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/bootstrap-slider/slider.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.css">

    <style type="text/css">
        #search {
            text-align: center;
            position: relative;
        }

        .autocomplete {
            border: 1px solid #9ACCFB;
            background-color: white;
            text-align: left;
        }

        .autocomplete li {
            list-style-type: none;
        }

        .clickable {
            cursor: default;
        }

        .highlight {
            background-color: #9ACCFB;
        }
    </style>


</head>


<body class="hold-transition skin-purple sidebar-mini">

<div class="wrapper">

    <!-- 页面头部 -->
    <jsp:include page="../home/header.jsp"></jsp:include>
    <!-- 页面头部 /-->
    <!-- 导航侧栏 -->
    <jsp:include page="../home/aside.jsp"></jsp:include>
    <!-- 导航侧栏 /-->

    <!-- 内容区域 -->
    <!-- @@master = admin-layout.html-->
    <!-- @@block = content -->

    <div class="content-wrapper">

        <!-- 内容头部 -->
        <section class="content-header">
            <h1>
                数据管理
                <small>数据列表</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                <li><a href="#">数据管理</a></li>
                <li class="active">数据列表</li>
            </ol>
        </section>
        <!-- 内容头部 /-->

        <!-- 正文区域 -->
        <section class="content">

            <!-- .box-body -->
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">列表</h3>
                </div>

                <div class="box-body">

                    <!-- 数据表格 -->
                    <div class="table-box">

                        <!--工具栏-->
                        <div class="pull-left">
                            <div class="form-group form-inline">
                                <div class="btn-group">
<%--                                    <button type="button" class="btn btn-default" title="新建"--%>
<%--                                            onclick="location.href='${pageContext.request.contextPath}/pages/basedata/product-add.jsp'">--%>
<%--                                        <i class="fa fa-file-o"></i> 新建--%>
<%--                                    </button>--%>
                                    <button type="button" class="btn btn-default" title="删除"
                                            onclick='deleteByIds()'>
                                        <i class="fa fa-trash-o"></i> 删除
                                    </button>
                                    <button type="button" onclick="updateStatus0ByIds()" class="btn btn-default"
                                            title="开启">
                                        <i class="fa fa-check"></i> 开启
                                    </button>
                                    <button type="button" onclick="updateStatus1ByIds()" class="btn btn-default"
                                            title="屏蔽">
                                        <i class="fa fa-ban"></i> 屏蔽
                                    </button>
                                    <button type="button" class="btn btn-default" title="刷新">
                                        <i class="fa fa-refresh"></i> 刷新
                                    </button>
                                </div>
                            </div>
                        </div>




                        <div class="box-tools pull-right">
                            <div class="has-feedback">


                                <form method="post" action="${pageContext.request.contextPath}/basedata/orders/findByLike?action=querybylike" id="listform">
                                    <div id = "search">
                                        <input type="text" name="keywords" class="input" />
                                        <input type="button" id="submit" value="搜索"/>
                                    </div>
                                </form>


<%--                                <input id="searchstr" name="searchstr" type="text" class="form-control input-sm"--%>
<%--                                       placeholder="搜索">--%>

<%--                                <div id="lns"></div>--%>
<%--                                <span--%>
<%--                                        class="glyphicon glyphicon-search form-control-feedback"></span>--%>
                            </div>
                        </div>








                        <!--工具栏/-->

                        <!--数据列表-->
                        <table id="dataList"
                               class="table table-bordered table-striped table-hover dataTable">
                            <thead>
                            <tr>
                                <th class="" style="padding-right: 0px;">
                                    <input name="selall" id="selall" type="checkbox" class="icheckbox_square-blue">
                                </th>
                                <th class="sorting_asc">ID</th>
                                <th class="sorting_desc">订单编号</th>
                                <th class="sorting_asc sorting_asc_disabled">产品名称</th>
                                <th class="sorting_desc sorting_desc_disabled">金额</th>
                                <th class="sorting">下单时间</th>
                                <th class="text-center sorting">订单状态</th>
                                <th class="text-center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
<%--                            <c:forEach items="${page.list}" var="o">--%>
<%--                                <tr>--%>
<%--                                    <td><input name="ids" value="${o.id}" type="checkbox"></td>--%>
<%--                                        &lt;%&ndash;										<td>1</td>&ndash;%&gt;--%>
<%--                                        &lt;%&ndash;										<td>1001001</td>&ndash;%&gt;--%>
<%--                                        &lt;%&ndash;										<td>海南一日游</td>&ndash;%&gt;--%>
<%--                                        &lt;%&ndash;										<td>3000</td>&ndash;%&gt;--%>
<%--                                        &lt;%&ndash;										<td>2020-10-10</td>&ndash;%&gt;--%>
<%--                                        &lt;%&ndash;										<td class="text-center">已下单</td>&ndash;%&gt;--%>
<%--                                    <td>${o.id}</td>--%>
<%--                                    <td>${o.orderNum}</td>--%>
<%--                                    <td>${o.product.productName}</td>--%>
<%--                                    <td>${o.product.productPrice}</td>--%>
<%--                                    <td>${o.orderTimeStr}</td>--%>
<%--                                    <td class="text-center">${o.orderStatus==0?'未下单':'已下单'}</td>--%>
<%--                                    <td class="text-center">--%>
<%--                                        <button type="button" class="btn bg-olive btn-xs"--%>
<%--                                                onclick="location.href='/travel/basedata/orders/findAllDetails?id=${o.id}'">--%>
<%--                                            详情--%>
<%--                                        </button>--%>
<%--                                    </td>--%>
<%--                                </tr>--%>

<%--                            </c:forEach>--%>


                            <c:forEach items="${orders}" var="orders">

                                <tr>
                                    <td><input name="ids" type="checkbox"></td>
                                    <td>${orders.id }</td>
                                    <td>${orders.orderNum }</td>
                                    <td>${orders.product.productName }</td>
                                    <td>${orders.product.productPrice }</td>
                                    <td>${orders.orderTimeStr }</td>
                                    <td class="text-center">${orders.orderStatus==0?'未下单':'已下单'}</td>
                                    <td class="text-center">
<%--                                        <button type="button" class="btn bg-olive btn-xs">订单</button>--%>
<%--                                        <button type="button" class="btn bg-olive btn-xs" onclick="location.href='${pageContext.request.contextPath}/pages/orders-show.jsp'">详情</button>--%>
<%--                                        <button type="button" class="btn bg-olive btn-xs">编辑</button>--%>

                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                            <!--
                        <tfoot>
                        <tr>
                        <th>Rendering engine</th>
                        <th>Browser</th>
                        <th>Platform(s)</th>
                        <th>Engine version</th>
                        <th>CSS grade</th>
                        </tr>
                        </tfoot>-->
                        </table>
                        <!--数据列表/-->

                    </div>
                    <!-- 数据表格 /-->


                </div>
                <!-- /.box-body -->
<%--                <button type="button" onclick="location.href='${pageContext.request.contextPath}/basedata/orders/turnTolist'" class="btn bg-olive btn-xs">返回</button>--%>

                <!-- .box-footer-->
                <div class="box-footer">
<%--                    <jsp:include page="/pages/common/page.jsp">--%>
<%--                        <jsp:param value="/travel/basedata/orders/findByPage" name="pageUrl"/>--%>
<%--                    </jsp:include>--%>

                </div>
                <!-- /.box-footer-->

                <div class="box-tools text-center">

                    <button type="button" class="btn bg-default"
                            onclick="location.href='${pageContext.request.contextPath}/basedata/orders/turnTolist'">返回</button>
                </div>

            </div>

        </section>
        <!-- 正文区域 /-->

    </div>
    <!-- @@close -->
    <!-- 内容区域 /-->

    <!-- 底部导航 -->
    <footer class="main-footer">
        <div class="pull-right hidden-xs">
            <b>Version</b> 1.0.8
        </div>
        <strong>Copyright &copy; 2014-2017 <a
                href="http://www.itcast.cn">研究院研发部</a>.
        </strong> All rights reserved.
    </footer>
    <!-- 底部导航 /-->

</div>


<script
        src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/jQueryUI/jquery-ui.min.js"></script>
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
<script
        src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/raphael/raphael-min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/morris/morris.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/sparkline/jquery.sparkline.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/knob/jquery.knob.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/daterangepicker/moment.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.zh-CN.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/datepicker/bootstrap-datepicker.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/fastclick/fastclick.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/iCheck/icheck.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/adminLTE/js/app.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/select2/select2.full.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.zh-CN.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/bootstrap-markdown.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/locale/bootstrap-markdown.zh.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/markdown.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/to-markdown.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/ckeditor/ckeditor.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.extensions.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/datatables/jquery.dataTables.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/chartjs/Chart.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.resize.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.pie.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.categories.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.min.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/bootstrap-slider/bootstrap-slider.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.js"></script>
<script
        src="${pageContext.request.contextPath}/plugins/bootstrap-datetimepicker/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script>
    function changePageSize() {
        //获取下拉框的值
        var pageSize = $("#changePageSize").val();

        //向服务器发送请求，改变没页显示条数
        location.href = "${pageContext.request.contextPath}/orders/findAll.do?page=1&pageSize="
            + pageSize;
    }

    $(document).ready(function () {
        // 选择框
        $(".select2").select2();

        // WYSIHTML5编辑器
        $(".textarea").wysihtml5({
            locale: 'zh-CN'
        });
    });

    // 设置激活菜单
    function setSidebarActive(tagUri) {
        var liObj = $("#" + tagUri);
        if (liObj.length > 0) {
            liObj.parent().parent().addClass("active");
            liObj.addClass("active");
        }
    }

    $(document).ready(function () {

        // 激活导航位置
        setSidebarActive("admin-datalist");

        // 列表按钮
        $("#dataList td input[type='checkbox']").iCheck({
            checkboxClass: 'icheckbox_square-blue',
            increaseArea: '20%'
        });
        // 全选操作
        $("#selall").click(function () {
            var clicks = $(this).is(':checked');
            if (!clicks) {
                $("#dataList td input[type='checkbox']").iCheck("uncheck");
            } else {
                $("#dataList td input[type='checkbox']").iCheck("check");
            }
            $(this).data("clicks", !clicks);
        });
    });
</script>
</body>

<script>


    //开启 按钮onclink事件
    function updateStatus0ByIds() {
        //获取复选对象
        let ids = document.getElementsByName("ids");
        let arr = new Array();

        for (var i = 0; i < ids.length; i++) {
            //判断出被选中的复选框
            if (ids[i].checked) {//true
                //alert(ids[i].value);
                //arr[i]=ids[i].value;
                arr.push(ids[i].value)

            }
        }
        alert(arr.length)
        alert(arr[0])
        //alert("ok:"+arr);
        //访问controller
        location.href = "/travel/basedata/orders/updateStatus0ByIds?ids=" + arr;
    }

    //屏蔽 按钮onclink事件
    function updateStatus1ByIds() {
        //获取复选对象
        let ids = document.getElementsByName("ids");
        let arr = new Array();

        for (var i = 0; i < ids.length; i++) {
            //判断出被选中的复选框
            if (ids[i].checked) {//true
                //alert(ids[i].value);
                //arr[i]=ids[i].value;
                arr.push(ids[i].value)

            }
        }
        // alert(arr.length)
        // alert(arr[0])
        //alert("ok:"+arr);
        //访问controller
        location.href = "/travel/basedata/orders/updateStatus1ByIds?ids=" + arr;
    }

    function deleteByIds() {
        //获取复选对象
        let ids = document.getElementsByName("ids");
        let arr = new Array();
        /*alert("ok:"+ids.length);*/
        for (var i = 0; i < ids.length; i++) {
            //判断出被选中的复选框
            if (ids[i].checked) {//true
                //alert(ids[i].value);
                //arr[i]=ids[i].value;
                arr.push(ids[i].value)

            }
        }
        alert(arr.length)
        alert(arr[0])
        //alert("ok:"+arr);
        //访问controller
        location.href = "/travel/basedata/orders/deleteByIds?ids=" + arr;
    }





</script>



<%--<script type="text/javascript" src="/plugins/jQuery/jquery-2.2.3.min.js"></script>--%>
<%--<script type="text/javascript">--%>
<%--    $(function () {--%>
<%--//取得div层--%>
<%--        var $search = $('#search');--%>
<%--//取得输入框JQuery对象--%>
<%--        var $searchInput = $search.find('#search-text');--%>
<%--//关闭浏览器提供给输入框的自动完成--%>
<%--        $searchInput.attr('autocomplete', 'off');--%>
<%--//创建自动完成的下拉列表，用于显示服务器返回的数据,插入在搜索按钮的后面，等显示的时候再调整位置--%>
<%--        var $autocomplete = $('<div class="autocomplete"></div>')--%>
<%--            .hide()--%>
<%--            .insertAfter('#submit');--%>
<%--//清空下拉列表的内容并且隐藏下拉列表区--%>
<%--        var clear = function () {--%>
<%--            $autocomplete.empty().hide();--%>
<%--        };--%>
<%--//注册事件，当输入框失去焦点的时候清空下拉列表并隐藏--%>
<%--        $searchInput.blur(function () {--%>
<%--            setTimeout(clear, 500);--%>
<%--        });--%>
<%--//下拉列表中高亮的项目的索引，当显示下拉列表项的时候，移动鼠标或者键盘的上下键就会移动高亮的项目，想百度搜索那样--%>
<%--        var selectedItem = null;--%>
<%--//timeout的ID--%>
<%--        var timeoutid = null;--%>
<%--//设置下拉项的高亮背景--%>
<%--        var setSelectedItem = function (item) {--%>
<%--//更新索引变量--%>
<%--            selectedItem = item;--%>
<%--//按上下键是循环显示的，小于0就置成最大的值，大于最大值就置成0--%>
<%--            if (selectedItem < 0) {--%>
<%--                selectedItem = $autocomplete.find('li').length - 1;--%>
<%--            } else if (selectedItem > $autocomplete.find('li').length - 1) {--%>
<%--                selectedItem = 0;--%>
<%--            }--%>
<%--//首先移除其他列表项的高亮背景，然后再高亮当前索引的背景--%>
<%--            $autocomplete.find('li').removeClass('highlight')--%>
<%--                .eq(selectedItem).addClass('highlight');--%>
<%--        };--%>
<%--        var ajax_request = function () {--%>
<%--//ajax服务端通信--%>
<%--            $.ajax({--%>
<%--                'url': '/basedata/orders/findByLike', //服务器的地址--%>
<%--                'data': {'search-text': $searchInput.val()}, //参数--%>
<%--                'dataType': 'json', //返回数据类型--%>
<%--                'type': 'POST', //请求类型--%>
<%--                'success': function (data) {--%>
<%--                    if (data.length) {--%>
<%--//遍历data，添加到自动完成区--%>
<%--                        $.each(data, function (index, term) {--%>
<%--//创建li标签,添加到下拉列表中--%>
<%--                            $('<li></li>').text(term).appendTo($autocomplete)--%>
<%--                                .addClass('clickable')--%>
<%--                                .hover(function () {--%>
<%--//下拉列表每一项的事件，鼠标移进去的操作--%>
<%--                                    $(this).siblings().removeClass('highlight');--%>
<%--                                    $(this).addClass('highlight');--%>
<%--                                    selectedItem = index;--%>
<%--                                }, function () {--%>
<%--//下拉列表每一项的事件，鼠标离开的操作--%>
<%--                                    $(this).removeClass('highlight');--%>
<%--//当鼠标离开时索引置-1，当作标记--%>
<%--                                    selectedItem = -1;--%>
<%--                                })--%>
<%--                                .click(function () {--%>
<%--//鼠标单击下拉列表的这一项的话，就将这一项的值添加到输入框中--%>
<%--                                    $searchInput.val(term);--%>
<%--//清空并隐藏下拉列表--%>
<%--                                    $autocomplete.empty().hide();--%>
<%--                                });--%>
<%--                        });//事件注册完毕--%>
<%--//设置下拉列表的位置，然后显示下拉列表--%>
<%--                        var ypos = $searchInput.position().top;--%>
<%--                        var xpos = $searchInput.position().left;--%>
<%--                        $autocomplete.css('width', $searchInput.css('width'));--%>
<%--                        $autocomplete.css({'position': 'relative', 'left': xpos + "px", 'top': ypos + "px"});--%>
<%--                        setSelectedItem(0);--%>
<%--//显示下拉列表--%>
<%--                        $autocomplete.show();--%>
<%--                    }--%>
<%--                }--%>
<%--            });--%>
<%--        };--%>
<%--//对输入框进行事件注册--%>
<%--        $searchInput--%>
<%--            .keyup(function (event) {--%>
<%--//字母数字，退格，空格--%>
<%--                if (event.keyCode > 40 || event.keyCode == 8 || event.keyCode == 32) {--%>
<%--//首先删除下拉列表中的信息--%>
<%--                    $autocomplete.empty().hide();--%>
<%--                    clearTimeout(timeoutid);--%>
<%--                    timeoutid = setTimeout(ajax_request, 100);--%>
<%--                } else if (event.keyCode == 38) {--%>
<%--//上--%>
<%--//selectedItem = -1 代表鼠标离开--%>
<%--                    if (selectedItem == -1) {--%>
<%--                        setSelectedItem($autocomplete.find('li').length - 1);--%>
<%--                    } else {--%>
<%--//索引减1--%>
<%--                        setSelectedItem(selectedItem - 1);--%>
<%--                    }--%>
<%--                    event.preventDefault();--%>
<%--                } else if (event.keyCode == 40) {--%>
<%--//下--%>
<%--//selectedItem = -1 代表鼠标离开--%>
<%--                    if (selectedItem == -1) {--%>
<%--                        setSelectedItem(0);--%>
<%--                    } else {--%>
<%--//索引加1--%>
<%--                        setSelectedItem(selectedItem + 1);--%>
<%--                    }--%>
<%--                    event.preventDefault();--%>
<%--                }--%>
<%--            })--%>
<%--            .keypress(function (event) {--%>
<%--//enter键--%>
<%--                if (event.keyCode == 13) {--%>
<%--//列表为空或者鼠标离开导致当前没有索引值--%>
<%--                    if ($autocomplete.find('li').length == 0 || selectedItem == -1) {--%>
<%--                        return;--%>
<%--                    }--%>
<%--                    $searchInput.val($autocomplete.find('li').eq(selectedItem).text());--%>
<%--                    $autocomplete.empty().hide();--%>
<%--                    event.preventDefault();--%>
<%--                }--%>
<%--            })--%>
<%--            .keydown(function (event) {--%>
<%--//esc键--%>
<%--                if (event.keyCode == 27) {--%>
<%--                    $autocomplete.empty().hide();--%>
<%--                    event.preventDefault();--%>
<%--                }--%>
<%--            });--%>
<%--//注册窗口大小改变的事件，重新调整下拉列表的位置--%>
<%--        $(window).resize(function () {--%>
<%--            var ypos = $searchInput.position().top;--%>
<%--            var xpos = $searchInput.position().left;--%>
<%--            $autocomplete.css('width', $searchInput.css('width'));--%>
<%--            $autocomplete.css({'position': 'relative', 'left': xpos + "px", 'top': ypos + "px"});--%>
<%--        });--%>
<%--    });--%>
<%--</script>--%>


</html>